<?php
include_once("config/config.inc.php");

if(isset($_POST["mb"]) && isset($_POST["rm"])) 
{
	$mb=$_POST["mb"];
	list($pre,$mb)=explode("_",$mb);
	$rm=$_POST["rm"];
	$qty=$_POST["qty"];
	$where=" where room_id='$rm' and minibar_id='$mb' ";
	$sql="select qty from room_minibar $where";
	$res =mysql_query($sql);
	if(mysql_num_rows($res)) {
		$usql="update room_minibar set qty=$qty $where ";
	}else{
		$usql=" insert into room_minibar (room_id, minibar_id, qty) values 
		('$rm','$mb','$qty')";
	}
	mysql_query($usql);
	exit;
}
?>